//
//  UIViewController+NBL.m
//  NBLiOSTools
//
//  Created by GangX-yangjh on 2021/12/11.
//

#import "UIViewController+NBL.h"
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>

@implementation UIViewController (NBL)

- (void)presentAVPlayer:(NSString *)videoUrl autoPlay:(BOOL)autoPlay
{
    // 弹出视频播放器
    NSURL *videoURL = [NSURL URLWithString:videoUrl];
    AVPlayerViewController *avPlayerViewController = [[AVPlayerViewController alloc] init];
    avPlayerViewController.player = [[AVPlayer alloc] initWithURL:videoURL];
    [self presentViewController:avPlayerViewController animated:YES completion:^{
        // 弹出完成自动播放
        [avPlayerViewController.player play];
    }];
}

@end
